/**
 * Copyright 2016-2017 TVI Go Easy.
 * Created on 2017/4/18 14:32
 */
package org.mechanic.fund.domain.product;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.mechanic.fund.domain.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 产品附件实体类
 *
 * @author mechanic
 * @version 0.0.1
 */
@Entity
@Table(name = "product_attachment")
public class ProductAttachment extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -4854059009511001244L;

    /**
     * 产品编号
     */
    @JsonIgnoreProperties({
      "parentId",
      "productStatus",
      "code",
      "productType",
      "isHotSelling",
      "isAssociation",
      "productStyle",
      "investmentManager",
      "level",
      "startMoney",
      "managerType",
      "managerName",
      "trusteeType",
      "trusteeName",
      "conditions",
      "issueBeginDate",
      "issueEndDate",
      "registerDate",
      "currency",
      "closePeriod",
      "expires",
      "recommendBeginDate",
      "recommendEndDate",
      "redemption",
      "productStocksIndexType",
      "newestNetvalue",
      "newestTotalNetvalue",
      "netvalueDate",
      "buyFee",
      "redemptionFee",
      "trusteeshipFee",
      "floatFee",
      "otherFee",
      "fixedFee",
      "openDate",
      "investmentScope",
      "recommendReason",
      "isDisclaimers",
      "remark"
    })
    @ManyToOne
    @JoinColumn(name = "product_id")
    private Product product;
    /**
     * 附件名称
     */
    @Column(name = "name")
    private String name;
    /**
     * 附件类型
     */
    @ManyToOne
    @JoinColumn(name = "product_attachment_type_id")
    @JsonIgnoreProperties(value = {"sort"})
    private ProductAttachmentType productAttachmentType;
    /**
     * 附件存放路径
     */
    @Column(name = "path")
    private String path;
    /**
     * 文件类型
     */
    @Column(name = "content_type")
    private String contentType;
    /**
     * 文件大小(MB)
     */
    @Column(name = "size")
    private BigDecimal size;

    public ProductAttachment() {
    }

    public ProductAttachment(
      String id,
      Product product,
      String name,
      ProductAttachmentType productAttachmentType,
      String path,
      String contentType,
      BigDecimal size,
      String createUser,
      LocalDateTime createTime,
      String updateUser,
      LocalDateTime updateTime) {
        this.id = id;
        this.product = product;
        this.name = name;
        this.productAttachmentType = productAttachmentType;
        this.path = path;
        this.contentType = contentType;
        this.size = size;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
    }

    public Product getProduct() {;
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ProductAttachmentType getProductAttachmentType() {
        return productAttachmentType;
    }

    public void setProductAttachmentType(ProductAttachmentType productAttachmentType) {
        this.productAttachmentType = productAttachmentType;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public BigDecimal getSize() {
        return size;
    }

    public void setSize(BigDecimal size) {
        this.size = size;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
